package com.jsgt.greekfire.ui.mainassets.coindetail.adapter

import android.content.Context
import android.text.TextUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.AssetDetailsResult
import com.jsgt.greekfire.bean.BillBean

class AssetDetailsAdapter(
    context: Context,
    layoutId: Int,
    data: ArrayList<BillBean>? = null
) : BaseQuickAdapter<BillBean, BaseViewHolder>(layoutId, data) {
    override fun convert(holder: BaseViewHolder, item: BillBean) {
        if (!TextUtils.isEmpty(item.createTime)) {
//            val termOfValidity: String = DateUtils.dealDateFormat(item.getCreateAt())
            holder.setText(R.id.tvTime, item.createTime)
        }
        holder.setText(R.id.tvName, item.assetEventStr)
        //1 充币  2 提现 3 买入 4 卖出 5 转账 6 收款 11 抢购
        when (item.direction) {
            0 -> {
                holder.setText(R.id.tvType, "[支出]")
                holder.setText(R.id.tvNum, "-" + item.assetAmt + symbol1)
                holder.setImageResource(R.id.ivType, R.mipmap.expenditure_image)
            }
            1 -> {
                holder.setText(R.id.tvType, "[收入]")
                holder.setText(R.id.tvNum, "+" + item.assetAmt)
                holder.setImageResource(R.id.ivType, R.mipmap.income_image)
            }
        }
    }

    private var symbol1 = ""

    fun setSymbol(symbol: String) {
        symbol1 = symbol
        notifyDataSetChanged()
    }
}
